import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login',
    },
    {
      path: '/button',
      name: 'button',
      component: () => import('../views/Button.vue'),
    },
    {
      path:'/manager',
      name:'manager',
      component:()=>import('../views/Manager.vue'),
      children:[
        {
          path:'/manager/employeeDataOp',
          name:'employeeDataOp',
          meta:{title:'员工数据操作'},
          component:()=>import('../views/employeeDataOp.vue')
        },
          {
            path:'/manager/home',
            name:'home',
            meta:{title:'首页'},
            component:()=>import('../views/home.vue')
          },
        {
          path:'/manager/adminDataOp',
          name:'adminDataOp',
          meta:{title:'管理员数据操作'},
          component:()=>import('../views/adminDataOp.vue')
        },
        {
          path:'/manager/person',
          name:'person',
          meta:{title:'个人信息'},
          component:()=>import('../views/Person.vue')
        },
        {
          path:'/manager/password',
          name:'password1',
          meta:{title:'修改密码'},
          component:()=>import('../views/modifyPassword.vue')
        },
        {
          path:'/manager/articleDataOp',
          name:'articleDataOp',
          meta:{title:'文章操作'},
          component:()=>import('../views/articleDataOp.vue')

        }      ]
    },
    {
      path:'/login',
      name:'login',
      meta:{title:'登录界面'},
      component:()=>import('../views/Login.vue')

    },
    {
      path:'/form',
      name:'form',
      component:()=>import('../views/form.vue')
    },
    {
      path:'/password',
      name:'password',
      meta:{title:'修改密码'},
      component:()=>import('../views/Password.vue')
    },
    {
      path:'/register',
      name:'register',
      meta:{title:'注册界面'},
      component:()=>import('../views/Register.vue')

    },
    {
      path:'/404',
      name:'404',
      meta:{title:'404'},
      component:()=>import('../views/404.vue')

    },
    {
      path:'/wangEditor',
      name:'wangEditor',
      meta:{title:'富文本编辑器'},
      component:()=>import('../views/WangEditor5Test.vue')
    },
    {
      path:'/:pathMatch(.*)*',
      redirect:'/404',

    }

  ],
})
router.beforeEach((to,from,next)=>{
    document.title=to.meta.title;
    next()
})

export default router
